package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.acticle.domain.Destination;
import cn.wolfcode.luowowo.acticle.domain.StrategyCatalog;
import cn.wolfcode.luowowo.acticle.query.DestinationQueryObject;
import cn.wolfcode.luowowo.acticle.query.StrategyCatalogQueryObject;
import cn.wolfcode.luowowo.acticle.service.IDestinationService;
import cn.wolfcode.luowowo.acticle.service.IStrategyCatalogService;
import cn.wolfcode.luowowo.acticle.service.IStrategyService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 攻略分类资源管理器
 */
@Controller
@RequestMapping("/strategyCatalog")
public class StrategyCatalogController {
    @Reference
    private IStrategyCatalogService strategyCatalogService;
    @Reference
    private IStrategyService strategyService;
    //大攻略分类列表
    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo") StrategyCatalogQueryObject qo){
        PageInfo pageInfo = strategyCatalogService .query(qo);
        model.addAttribute("pageInfo", pageInfo);
        model.addAttribute("strategies", strategyService.listAll()); //大攻略数据
        return "strategyCatalog/list";
    }
    
    //保存攻略分类
    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(StrategyCatalog strategyCatalog){
        strategyCatalogService.saveOrUpdate(strategyCatalog);
        return new AjaxResult();
    }
    //删除攻略分类
    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(Long id){
        strategyCatalogService.delete(id);
        return new AjaxResult();
    }
}
